﻿#pragma once

#include "geom/geom_curve.h"
#include "geom/geom_surface.h"

namespace CAGD
{

class Projection
{
  public:
    /**
     * @brief 最近点投影.
     * @return
     * @param curve
     * @param P
     * @param t
     * @param Q
     * @param tol
     * @see
     */
    static double Near(Handle(GeomCurve) curve, BPnt P, double &t, BPnt &Q, double tol);

    /**
     * @brief 正交点投影，一阶切线法.
     * @return
     * @param curve
     * @param P
     * @param t
     * @param Q
     * @param tol
     * @see
     */
    static double Ortho1(Handle(GeomCurve) curve, BPnt P, double &t, BPnt &Q, double tol);

    /**
     * @brief 正交点投影，二阶曲率圆法.
     * @return
     * @param curve
     * @param P
     * @param t
     * @param Q
     * @param tol
     * @see
     */
    static double Ortho2(Handle(GeomCurve) curve, BPnt P, double &t, BPnt &Q, double tol);

    /**
     * @brief 最近点投影.
     * @return
     * @param surface
     * @param P
     * @param u
     * @param v
     * @param Q
     * @param tol
     * @see
     */
    static double Near(Handle(GeomSurface) surface, BPnt P, double &u, double &v, BPnt &Q, double tol);

    /**
     * @brief 切平面正交点投影.
     * @return
     * @param surface
     * @param P
     * @param u
     * @param v
     * @param Q
     * @param tol
     * @see
     */
    static double Ortho1(Handle(GeomSurface) surface, BPnt P, double &u, double &v, BPnt &Q, double tol);

    /**
     * @brief 曲率圆正交点投影.
     * @return
     * @param surface
     * @param P
     * @param u
     * @param v
     * @param Q
     * @param tol
     * @see
     */
    static double Ortho2(Handle(GeomSurface) surface, BPnt P, double &u, double &v, BPnt &Q, double tol);

    /**
     * @brief 圆环面曲率投影算法.
     * @return
     * @param surface
     * @param P
     * @param u
     * @param v
     * @param Q
     * @param tol
     * @see
     */
    static double Torus(Handle(GeomSurface) surface, BPnt P, double &u, double &v, BPnt &Q, double tol);

    /**
     * @brief 步进修正投影法.
     * @param curve
     * @param surface
     * @param t0
     * @param t1
     * @param N
     * @param tol
     * @param Para
     * @see
     */
    static void March(Handle(GeomCurve) curve, Handle(GeomSurface) surface, double t0, double t1, int N, double tol,
                      std::vector<BPnt2d> &Para);

    /**
     * @brief 微分方程求解投影法.
     * @param curve
     * @param surface
     * @param t0
     * @param t1
     * @param N
     * @param tol
     * @param Para
     * @see
     */
    static void ODE(Handle(GeomCurve) curve, Handle(GeomSurface) surface, double t0, double t1, int N, double tol,
                    std::vector<BPnt2d> &Para);
};

} // namespace CAGD
